package de.stefangoebel.aufgabenplaner;

import java.util.Calendar;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.widget.TextView;


public class PieChartActivity extends Activity {
	public static final String PIECHART_DATE = "PieChartDate";
	public static final String PIECHART_CATEGORY = "PieChartCategory";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_piechart);
		
		Calendar date = Misc.getDateFromString(getIntent().getExtras().getString(PIECHART_DATE));
		TextView txtDate = (TextView)findViewById(R.id.txt_PieChartDate);
		txtDate.setTag(DateFormat.getDateFormat(this).format(date.getTime()));
		
		String category[] = getResources().getStringArray(R.array.pref_aufgabe_category_titles);
		
		PieChart pie = (PieChart)findViewById(R.id.PieChart);
		for(int i = 1; i < category.length; i++) {
			pie.addItem(category[i], getIntent().getExtras().getInt(PIECHART_CATEGORY + String.valueOf(i)), getResources().getColor(Misc.getResId("category" + String.valueOf(i), this, R.color.class)));
		}
		pie.addItem(category[0], getIntent().getExtras().getInt(PIECHART_CATEGORY + "0"), getResources().getColor(Misc.getResId("category0", this, R.color.class)));
	}
}
